package 补充.输入输出操作.文件操作;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;

public class 对象流序列化 {
    public static void main(String[] args) throws IOException {
        Student1 s=new Student1(10,"lily");
        FileOutputStream fos=new FileOutputStream("D:\\Learn\\javademo\\untitled\\src\\补充_偏\\输入输出操作\\read.txt");
        ObjectOutputStream oos=new ObjectOutputStream(fos);
        oos.writeObject(s);
    }
}
class Student implements Serializable {
    public Integer id;
    public String name;
    public Student(Integer id, String name){
        this.id = id;
        this.name = name;
    }
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
}
